//
//  HJDFileViewCell.m
//  JYHospital
//
//  Created by 胡金东 on 16/5/17.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDFileViewCell.h"
#define HJDTimeH 25

@interface HJDFileViewCell ()



@end

@implementation HJDFileViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.dateLbl = [[UILabel alloc]initWithFrame:CGRectZero];
        self.dateLbl.textColor = [UIColor getColorWithHexNumber:@"323232"];
        self.dateLbl.font = [UIFont systemFontOfSize:19];
        [self addSubview:self.dateLbl];
        
        self.yearLbl = [[UILabel alloc]initWithFrame:CGRectZero];
        self.yearLbl.textColor = [UIColor getColorWithHexNumber:@"BCBCBC"];
        self.yearLbl.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.yearLbl];
        
        self.blbl = [[UIView alloc]initWithFrame:CGRectZero];
        self.blbl.backgroundColor = [UIColor getColorWithHexNumber:@"FBFBFB"];
        [self addSubview:self.blbl];

    
        self.nameLbl = [[UILabel alloc]initWithFrame:CGRectZero];
        self.nameLbl.textColor = [UIColor getColorWithHexNumber:@"323232"];
        self.nameLbl.font = [UIFont systemFontOfSize:15];
        [self.blbl addSubview:self.nameLbl];
        
        self.cnameLbl = [[UILabel alloc]initWithFrame:CGRectZero];
        self.cnameLbl.textColor = [UIColor getColorWithHexNumber:@"323232"];
        self.cnameLbl.font = [UIFont systemFontOfSize:15];
        [self.blbl addSubview:self.cnameLbl];
        
        self.projectLbl = [[UILabel alloc]initWithFrame:CGRectZero];
        self.projectLbl.textColor = [UIColor getColorWithHexNumber:@"848484"];
        self.projectLbl.font = [UIFont systemFontOfSize:15];
        [self.blbl addSubview:self.projectLbl];
        
        self.cprojectLbl = [[UILabel alloc]initWithFrame:CGRectZero];
        self.cprojectLbl.textColor = [UIColor getColorWithHexNumber:@"848484"];
        self.cprojectLbl.font = [UIFont systemFontOfSize:15];
        self.cprojectLbl.numberOfLines = 0;
        [self.blbl addSubview:self.cprojectLbl];
        
        self.numLbl = [[UILabel alloc]initWithFrame:CGRectZero];
        self.numLbl.textColor = [UIColor grayColor];
        self.numLbl.font = [UIFont systemFontOfSize:15];
        [self.blbl addSubview:self.numLbl];
        
        self.cnumLbl = [[UILabel alloc]initWithFrame:CGRectZero];
        self.cnumLbl.textColor = [UIColor getColorWithHexNumber:@"848484"];
        self.cnumLbl.font = [UIFont systemFontOfSize:15];
        [self.blbl addSubview:self.cnumLbl];
        
        self.weekLbl = [[UILabel alloc]initWithFrame:CGRectZero];
        self.weekLbl.textColor = [UIColor getColorWithHexNumber:@"848484"];
        self.weekLbl.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.weekLbl];
        
        self.ImageView = [[UIImageView  alloc]initWithFrame:CGRectZero];
        self.ImageView.image = [UIImage imageNamed:@"图层-35-拷贝"];
        
        [self addSubview:self.ImageView];

    }
    return self;
}

-(void)layoutSubviews
{
    CGFloat dateX = HJDHorizontalMargin/2;
    CGFloat dateY = HJDVerticalMargin/2;
    CGSize dateSize = [_dateLbl.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.dateLbl.font,NSFontAttributeName, nil]];
    self.dateLbl.frame = (CGRect){{dateX,dateY},dateSize};
    
    CGFloat yearX = CGRectGetMaxX(self.dateLbl.frame);
    CGFloat yearY = HJDVerticalMargin/2 +6;
    CGSize yearSize = [_yearLbl.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.yearLbl.font,NSFontAttributeName, nil]];
    self.yearLbl.frame = (CGRect){{yearX,yearY},yearSize};
    
    CGFloat blblX = 0;
    CGFloat blblY = CGRectGetMaxY(self.dateLbl.frame) + HJDVerticalMargin/2;
    CGFloat blblW = HJDWidth;
    CGFloat blblH = 100;
    self.blbl.frame = CGRectMake(blblX, blblY, blblW, blblH);

    CGFloat nameX = HJDHorizontalMargin/2;
    CGFloat nameY = 10;
    CGSize nameSize = [_nameLbl.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.nameLbl.font,NSFontAttributeName, nil]];
    self.nameLbl.frame = (CGRect){{nameX,nameY},nameSize};
    
    CGFloat cnameX = CGRectGetMaxX(self.nameLbl.frame);
    CGFloat cnameY = nameY;
    CGSize cnameSize = [_cnameLbl.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.cnameLbl.font,NSFontAttributeName, nil]];
    self.cnameLbl.frame = (CGRect){{cnameX,cnameY},cnameSize};


    CGFloat projectX = HJDHorizontalMargin/2 ;
    CGFloat projectY = CGRectGetMaxY(self.nameLbl.frame) + 3;
    
    CGSize projectSize = [_projectLbl.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.projectLbl.font,NSFontAttributeName, nil]];

    self.projectLbl.frame = (CGRect){{projectX,projectY},projectSize};
    
    CGFloat cprojectX = CGRectGetMaxX(self.projectLbl.frame) ;
    CGFloat cprojectY = projectY;
    CGFloat cprojectW = HJDWidth - HJDHorizontalMargin * 2 -60;
    CGRect cprojectRect = [_cprojectLbl.text boundingRectWithSize:CGSizeMake(cprojectW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:self.cprojectLbl.font,NSFontAttributeName, nil] context:nil];
    self.cprojectLbl.frame = (CGRect){{cprojectX,cprojectY},cprojectRect.size};

    CGFloat numX = HJDHorizontalMargin/2;
    CGFloat numY = CGRectGetMaxY(self.cprojectLbl.frame) + 3;
    CGSize numSize = [_numLbl.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.numLbl.font,NSFontAttributeName, nil]];
    self.numLbl.frame = (CGRect){{numX,numY},numSize};
    
    CGFloat cnumX = CGRectGetMaxX(self.numLbl.frame);
    CGFloat cnumY = numY;
    CGSize cnumSize = [_cnumLbl.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.cnumLbl.font,NSFontAttributeName, nil]];
    self.cnumLbl.frame = (CGRect){{cnumX,cnumY},cnumSize};
    

    CGFloat weekX = HJDWidth - HJDHorizontalMargin*3;
    CGFloat weekY = CGRectGetMaxY(self.blbl.frame) + HJDVerticalMargin;
    CGSize weekSize = [_weekLbl.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.weekLbl.font,NSFontAttributeName, nil]];
    self.weekLbl.frame = (CGRect){{weekX,weekY},weekSize};
    
    CGFloat ImageViewX = HJDWidth - HJDHorizontalMargin *5;
    CGFloat ImageViewY = weekY;
    CGFloat ImageViewW = weekSize.width;
    CGFloat ImageViewH = weekSize.height;
  
    self.ImageView.frame = CGRectMake(ImageViewX, ImageViewY, ImageViewW, ImageViewH);

    
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
        UIColor *backgroundColor = self.blbl.backgroundColor;
    [super setHighlighted:highlighted animated:animated];
   
    self.blbl.backgroundColor = backgroundColor;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    UIColor *backgroundColor = self.blbl.backgroundColor;
    [super setSelected:selected animated:animated];
    

    self.blbl.backgroundColor = backgroundColor;
}




@end
